package org.rcy.ruicingmarket.config;

import feign.Feign;
import feign.codec.Decoder;
import feign.codec.Encoder;
import org.rcy.ruicingmarket.goods.GoodsClient;
import org.rcy.ruicingmarket.interceptor.FeignInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 吴康桥
 * @Description
 * @date 2023/5/9 15:35
 */

@Configuration
public class GoodsClientConfiguration {

	private FeignInterceptor feignInterceptor = new FeignInterceptor();

	@Value("${rcy.gatewayurl:http://localhost:9019}")
	private String gatewayUrl;

	@Bean
	public GoodsClient goodsClient(Encoder encoder, Decoder decoder) {
		return Feign.builder()
				.decoder(decoder).encoder(encoder)
				.requestInterceptor(feignInterceptor)
				.target(GoodsClient.class,gatewayUrl);
	}

}
